/**
 * 
 */
package cardbs.servlets;

import static cardbs.dao.DAOFactory.*;
import static cardbs.dao.DepartmentDAO.*;
import static cardbs.domain.Department.*;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import java.io.IOException;
import java.util.*;
import cardbs.dao.DAOFactory;
import cardbs.dao.DepartmentDAO;
import cardbs.dao.EmployeeDAO;
import cardbs.domain.Department;
import cardbs.domain.Employee;

/** 
 * <!-- begin-UML-doc -->
 * <!-- end-UML-doc -->
 * @author marianna
 * @generated "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
 */
public class CreatePartServlet  extends HttpServlet{
	public CreatePartServlet() {
		// TODO Auto-generated constructor stub
	}
	/** 
	 * <!-- begin-UML-doc -->
	 * <!-- end-UML-doc -->
	 * @param request
	 * @param response
	 * @generated "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response) {
		// begin-user-code
		// TODO Auto-generated method stub

		DAOFactory daoFactory = DAOFactory.getInstance();
		DepartmentDAO departmentDAO = daoFactory.getDepartmentDAO();
		Set<Department> departments = departmentDAO.findAllDepartments();
		HttpSession sess = request.getSession(true);
		sess.setAttribute("depList", departments);
		if(request.getParameter("enimerosi") != null){
		String url = "/car-dbs-implementation/uipages/adminpages/enimerosiAntallaktikou.jsp";
		try {
			response.sendRedirect(url);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		} else {
		String url = "/car-dbs-implementation/uipages/adminpages/eisagogiAntallaktikou.jsp";
		try {
			response.sendRedirect(url);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		}
		// end-user-code
	}
}